Skip to content

Conversation

@S-Granevich
Copy link

No description provided.

Copy link
Owner

@gemtechd gemtechd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you throw an error about a function parameter
the user should now exactly what is the problem

class Line {
constructor({ point1 = new Point(), point2 = new Point(), n = undefined, slope = undefined }) {
if((!(point1 instanceof(Point))) || (!(point2 instanceof Point))){
throw new Error("The entered arguments is not valid!")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which parameter one is invalid?

class Point {
constructor({x=0, y=0}={}) {
if(typeof(x)!=="number"||typeof(y)!=="number"){
throw new Error("the function should get number")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the x or the y or both are invalid?


if (line1.slope === line2.slope) {
if (line1.n === line2.n) {
return true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when the slope or n are not calculated?

}

const proxyLine = new Line({ point1: line.point1, point2: point })
proxyLine.calculateSlope()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if the line.slope is still undefined?

package.json Outdated
"coverage":"npm run test -- --coverage"
},
"dependencies": {
"jest": "^29.7.0"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jest shouldn't be in the dependecies section

let lineTest=new Line({})

describe ('ERRORS',()=>{
it('Error checker for constructor',()=>{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are the good tests for the constructor?

it('should calculate the slop', () => {
line.calculateSlope()
expect(line.slope).toBe(1)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are the errors for the function?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing the tests for the constructor...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write the tests again
did you understand the purpose of mocks (it's written un your presentation)?
So use them
and test correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants